package com.czkt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.czkt.mapper.SysRoleRightMapper;
import com.czkt.pojo.SysRight;
import com.czkt.pojo.SysRoleRight;
import com.czkt.pojo.SysUser;
import com.czkt.mapper.SysUserMapper;
import com.czkt.pojo.vo.SysUserVo;
import com.czkt.service.ISysUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2024-06-19
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
    @Autowired
    SysUserMapper sysUserMapper;

    @Autowired
    SysRoleRightMapper sysRoleRightMapper;

    @Override
    public SysUserVo getUserByLogin(String usrName, String usrPassword) {
        return sysUserMapper.getUserByLogin(usrName, usrPassword);
    }

    @Override
    public SysUserVo getUserByName(String usrName) {
        return sysUserMapper.getUserByName(usrName);
    }

    @Override
    public IPage<SysUserVo> selectPageVo(IPage<SysUserVo> page, SysUserVo sysUserVo) {
        return sysUserMapper.selectPageVo(page,sysUserVo);
    }

    @Override
    public List<SysRoleRight> getSysRoleById(long roleId) {
        LambdaQueryWrapper<SysRoleRight> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(roleId != 0,SysRoleRight::getRfRoleId,roleId);
        return sysRoleRightMapper.selectList(queryWrapper);
    }

}
